
package com.uuah.server.api.transport;

import java.beans.ExceptionListener;

import com.uuah.api.INamedObject;
import com.uuah.api.lifecycle.ILifecycle;
import com.uuah.server.api.IUuahContext;
import com.uuah.server.api.IUuahEvent;
import com.uuah.server.api.IUuahMessage;
import com.uuah.server.api.component.service.IService;
import com.uuah.server.api.context.IUuahContextAware;
import com.uuah.server.api.endpoint.IUuahEndpoint;
import com.uuah.server.api.transformer.IBaseTransformer;
import com.uuah.server.api.transport.retry.RetryPolicyTemplate;
import com.uuah.server.exception.MessagingException;
import com.uuah.server.exception.transport.DispatchException;


public interface IConnector extends ILifecycle, IUuahContextAware, INamedObject {
	int INT_VALUE_NOT_SET = -1;


	IMessageReceiver registerListener(IService service, IUuahEndpoint endpoint)
			throws Exception;


	void unregisterListener(IService service, IUuahEndpoint endpoint)
			throws Exception;

	boolean isStarted();

	boolean isConnected();

	boolean isConnecting();

	boolean isDisposed();

	boolean isDisposing();

	IMessageAdapter getMessageAdapter(Object message) throws MessagingException;

	String getProtocol();

	boolean supportsProtocol(String protocol);

	void setExceptionListener(ExceptionListener listener);

	ExceptionListener getExceptionListener();

	void handleException(Exception exception);

	void setDispatcherFactory(IMessageDispatcherFactory factory);

	IMessageDispatcherFactory getDispatcherFactory();

	boolean isSyncEnabled(String protocol);

	void dispatch(IUuahEndpoint endpoint, IUuahEvent event)
			throws DispatchException;

	IUuahMessage send(IUuahEndpoint endpoint, IUuahEvent event)
			throws DispatchException;

	IUuahContext getUuahContext();

	RetryPolicyTemplate getRetryPolicyTemplate();

	IBaseTransformer getDefaultRequestTransformer();

	IBaseTransformer getDefaultResponseTransformer();

	void dispatch(IUuahMessage result, IUuahEvent event);
}
